package com.lh.jsp.urlparamEncoding;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class TestURLEncoded {	
	public static String Encoded(String s){
		String temp="";
		try {
			temp = URLEncoder.encode(s,"UTF-8");
		} catch (UnsupportedEncodingException e) {
			System.out.println("encode error.");
		}
		return temp;
	}
	public static String decoded(String s){
		String temp="";
		try {
			temp = URLDecoder.decode(s, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			System.out.println("decode error.");
		}
		return temp;
	}
	public static void main(String[] args) {
		String s = "Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
		System.out.println("s encode="+TestURLEncoded.Encoded(s));
		System.out.println("s decode="+TestURLEncoded.decoded(s));

	}

}
